package jwdt.xadmin.rskq.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.rskq.bean.TKqdj;
import jwdt.xadmin.rskq.bean.TKqjb;
import jwdt.xadmin.rskq.bean.TKqqj;
import jwdt.xadmin.rskq.bean.TKqwc;
import jwdt.xadmin.rskq.service.KqcxManageService;
import jwdt.xadmin.rskq.service.KqdjManageService;
import jwdt.xadmin.rskq.service.KqjbManageService;
import jwdt.xadmin.rskq.service.KqqjManageService;
import jwdt.xadmin.rskq.service.KqwcManageService;
import jwdt.xadmin.system.bean.TUser;

import com.ezerg.db.Jdb;
import com.ezerg.db.ext.PageUtil;
import com.ezerg.util.DateUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/rskq")
public class KqManageAction extends BaseAction {
	protected String url = "/xadmin/rskq/";
	
	private KqcxManageService kqcxManageService = (KqcxManageService)app.getBean("kqcxManageService");
	private KqdjManageService kqdjManageService = (KqdjManageService)app.getBean("kqdjManageService");
	private KqjbManageService kqjbManageService = (KqjbManageService)app.getBean("kqjbManageService");
	private KqwcManageService kqwcManageService = (KqwcManageService)app.getBean("kqwcManageService");
	private KqqjManageService kqqjManageService = (KqqjManageService)app.getBean("kqqjManageService");
	
	@RequestMapping("/kqjbManage")
	public Page doKqjbManage(Form f, Module m) throws Exception {
		return m.findPage(url + "kqjbManage");
	}
	
	@RequestMapping("/kqdjEdit")
	public Page doKqdjEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqdj obj = (TKqdj) Jdb.get().get(TKqdj.class, id);
		f.add("obj", obj);
		return m.findPage(url + "kqdjEdit");
	}
	
	@RequestMapping("/kqdjEditact")
	public Page doKqdjEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqdj obj = (TKqdj)f.copy2Class(TKqdj.class);
		return m.getWritePage(f, kqdjManageService.kqdjEditact(obj, id));
	}
	
	@RequestMapping("/kqdjckbz")
	public Page doKqdjckbz(Form f, Module m) throws Exception {
		return m.findPage(url + "kqdjEdit");
	}
	
	@RequestMapping("/kqdjbz")
	public Page doKqqdjbz(Form f, Module m) throws Exception {
		//
		Integer id=f.getInt("id");
		String bz=f.getString("bz");
		f.add("ret",kqdjManageService.kqdjbz(f, m, id, bz));
		return m.getRedirectPage(url + "kqdjManage.do");
	}
	
	@RequestMapping("/kqjbcheck")
	public Page doKqjbCheck(Form f, Module m) throws Exception {
		//
		
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqjb tc = (TKqjb)f.copy2Class(TKqjb.class);
		return m.getWritePage(f,kqjbManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqjbadd")
	public Page doKqjbAdd(Form f, Module m) throws Exception {
		//
		String sql=" where OSKEY='user'";
		f.add("kqjb_bm", kqcxManageService.tdep());
		f.add("kqjb_spr",kqcxManageService.tuser(sql));	
		f.add("now", DateUtil.getDateTime());
		return m.findPage(url + "kqjbAdd");
	}
	
	@RequestMapping("/kqjbaddact")
	public Page doKqjbAddact(Form f, Module m) throws Exception {
		//
		TKqjb obj = (TKqjb) f.copy2Class(TKqjb.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		return m.getWritePage(f, kqjbManageService.kqjbAddact(obj, userInfo));
	}
	
	@RequestMapping("/kqjbedit")
	public Page doKqjbEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqjb obj = (TKqjb) Jdb.get().get(TKqjb.class, id);
		f.add("obj", obj);
		f.add("kqjb_zt",kqcxManageService.getFlmx(11));
		return m.findPage(url + "kqjbEdit");
	}
	
	@RequestMapping("/kqjbeditact")
	public Page doKqjbEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqjb obj = (TKqjb)f.copy2Class(TKqjb.class);
		return m.getWritePage(f, kqjbManageService.kqjbEditact(obj, id));
	}
	
	
	@RequestMapping("/kqjbdel")
	public Page doKqjbDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		return m.getWritePage(f, kqjbManageService.kqjbDel(id));
	}
	
	@RequestMapping("/kqdjManage")
	public Page doKqdjManage(Form f, Module m) throws Exception {
		//
		String timea = f.getString("timea");
		String timeb = f.getString("timeb");
		f.add("sbsjcx", kqcxManageService.sbsjcx(timea, timeb));
		String nowDate = DateUtil.getDate();
		f.add("nowDate", nowDate);
		f.add("sbsjbz", "08:00:00");
		f.add("xbsjbz", "18:00:00");
		int djid = Jdb.get().queryForInt("select id from t_kq_dj where recorddate=?",new Object[]{nowDate});
		if(djid!=0){
			TKqdj dj = (TKqdj) Jdb.get().get(TKqdj.class, djid);
			f.add("sbsj", dj.getSigndatetime1());
			f.add("xbsj", dj.getSigndatetime2());
		}
		f.add("pager", kqcxManageService.page(f, m));
		return m.findPage(url + "kqdjManage");
	}
	
	@RequestMapping("/kqdjsbsj")
	public Page doKqdjsbsj(Form f, Module m) throws Exception {
		//
		TUser userInfo = (TUser) f.getSession("userInfo");
		TKqdj obj = (TKqdj) f.copy2Class(TKqdj.class);
		obj.setSigndatetime1(DateUtil.getDateTime());
		obj.setUserid(userInfo.getUserid());
		String nowDate = DateUtil.getDate();
		obj.setRecorddate(nowDate);
		f.add("ret",kqdjManageService.kqdjsbsj(obj));
		return m.getRedirectPage(url + "kqdjManage.do");
	}
	
	@RequestMapping("/kqdjxbsj")
	public Page doKqdjxbsj(Form f, Module m) throws Exception {
		//
		String nowDate = DateUtil.getDate();
		f.add("ret", kqdjManageService.kqdjxbsj(f, nowDate));
		return m.getRedirectPage(url + "kqdjManage.do");
	}
	
	@RequestMapping("/kqcxcheckdj")
	public Page doCheckdj(Form f, Module m) throws Exception {
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqdj tc = (TKqdj)f.copy2Class(TKqdj.class);
		return m.getWritePage(f,kqdjManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqcxcheckwc")
	public Page doCheckwc(Form f, Module m) throws Exception {

		//
		String flag = "1";
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqwc tc = (TKqwc)f.copy2Class(TKqwc.class);
		return m.getWritePage(f,kqwcManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqcxcheckqj")
	public Page doCheckqj(Form f, Module m) throws Exception {

		//
		String flag = "1";
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqqj tc = (TKqqj)f.copy2Class(TKqqj.class);
		return m.getWritePage(f,kqqjManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqcxcheckjb")
	public Page doCheckjb(Form f, Module m) throws Exception {

		//
		String flag = "1";
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqjb tc = (TKqjb)f.copy2Class(TKqjb.class);
		return m.getWritePage(f,kqjbManageService.doList(pu,tc,flag).toJson());	
	}

	@RequestMapping("/kqqjManage")
	public Page doKqqjManage(Form f, Module m) throws Exception {
		return m.findPage(url + "kqqjManage");
	}
	
	@RequestMapping("/kqqjcheck")
	public Page doKqqjCheck(Form f, Module m) throws Exception {
		//
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqqj tc = (TKqqj)f.copy2Class(TKqqj.class);
		return m.getWritePage(f,kqqjManageService.doList(pu,tc,flag).toJson());	
		
	}
	
	@RequestMapping("/kqqjadd")
	public Page doKqqjAdd(Form f, Module m) throws Exception {
		//
		String sql=" where OSKEY='user'";
		f.add("kq_qj_spr",kqcxManageService.tuser(sql));
		f.add("kq_qj_qjbm",kqcxManageService.tdep());
		f.add("kq_qj_qjlx",kqcxManageService.getFlmx(9));
		return m.findPage(url + "kqqjAdd");
	}
	
	@RequestMapping("/kqqjaddact")
	public Page doKqqjAddact(Form f, Module m) throws Exception {
		//
		TKqqj obj = (TKqqj) f.copy2Class(TKqqj.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		return m.getWritePage(f, kqqjManageService.kqqjaddact(obj, userInfo));
		
	}
	
	@RequestMapping("/kqqjedit")
	public Page doKqqjEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		f.add("obj", kqqjManageService.kqqjedit(id));
		f.add("kqqjzt",kqcxManageService.getFlmx(11));
		return m.findPage(url + "kqqjEdit");
	}
	
	@RequestMapping("/kqqjeditact")
	public Page doKqqjEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqqj obj = (TKqqj) f.copy2Class(TKqqj.class);
		return m.getWritePage(f, kqqjManageService.kqqjEditact(obj, id));
	}
	
	@RequestMapping("/kqqjdel")
	public Page doKqqjDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		return m.getWritePage(f,  kqqjManageService.kqqjdel(id));
	}
	
	@RequestMapping("/kqspManage")
	public Page doKqspManage(Form f, Module m) throws Exception {
		return m.findPage(url + "kqspManage");
	}
	
	@RequestMapping("/kqspCheck")
	public Page doKqspCheck(Form f, Module m) throws Exception {
		//
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqjb tc = (TKqjb)f.copy2Class(TKqjb.class);
		return m.getWritePage(f,kqjbManageService.doList(pu,tc,flag).toJson());	
		
	}
	
	@RequestMapping("/kqjbSpb")
	public Page doKqjbSpb(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		kqjbManageService.kqjbSpb(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	}
	
	@RequestMapping("/kqjbSpt")
	public Page doKqjbSpt(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		kqjbManageService.kqjbSpt(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	} 
	
	@RequestMapping("/kqqjSpb")
	public Page doKqqjSpb(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		kqqjManageService.kqqjSpb(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	}
	
	@RequestMapping("/kqqjSpt")
	public Page doKqqjSpt(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		kqqjManageService.kqqjSpt(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	}
	
	@RequestMapping("/kqwcSpb")
	public Page doKqwcSpb(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		kqwcManageService.kqwcSpb(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	}
	
	@RequestMapping("/kqwcSpt")
	public Page doKqwcSpt(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		kqwcManageService.kqwcSpt(f, m, id);
		return m.getRedirectPage(url + "kqspManage.do");
	}
	
	@RequestMapping("/kqspWaichu")
	public Page doWaichu(Form f, Module m) throws Exception {
		//
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqwc tc = (TKqwc)f.copy2Class(TKqwc.class);
		return m.getWritePage(f,kqwcManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqspQingjia")
	public Page doQingjia(Form f, Module m) throws Exception {
		//
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqqj tc = (TKqqj)f.copy2Class(TKqqj.class);
		return m.getWritePage(f,kqqjManageService.doList(pu,tc,flag).toJson());	
	}

	@RequestMapping("/kqwcManage")
	public Page doKqwcManage(Form f, Module m) throws Exception {
		return m.findPage(url + "kqwcManage");
	}
	
	@RequestMapping("/kqwccheck")
	public Page doKqwcCheck(Form f, Module m) throws Exception {
		//
		String flag = f.getString("flag");
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TKqwc tc = (TKqwc)f.copy2Class(TKqwc.class);
		return m.getWritePage(f,kqwcManageService.doList(pu,tc,flag).toJson());	
	}
	
	@RequestMapping("/kqwcadd")
	public Page doKqwcAdd(Form f, Module m) throws Exception {
		//
		f.add("kqwc_spr",kqcxManageService.tuser(" where OSKEY='user'"));
		return m.findPage(url + "kqwcAdd");
	}
	
	@RequestMapping("/kqwcaddact")
	public Page doKqwcAddact(Form f, Module m) throws Exception {
		//
		TKqwc obj = (TKqwc) f.copy2Class(TKqwc.class);
		TUser userInfo = (TUser) f.getSession("userInfo");
		return m.getWritePage(f, kqwcManageService.kqwcaddact(obj, userInfo));
	}
	
	@RequestMapping("/kqwcedit")
	public Page doKqwcEdit(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		f.add("obj", kqwcManageService.kqwcedit(id));
		f.add("kqwc_zt",kqcxManageService.getFlmx(11));
		return m.findPage(url + "kqwcEdit");
	}

	@RequestMapping("/kqwceditact")
	public Page doKqwcEditact(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");
		TKqwc obj = (TKqwc) f.copy2Class(TKqwc.class);
		return m.getWritePage(f, kqwcManageService.kqwcEditact(obj, id));
	}

	@RequestMapping("/kqwcdel")
	public Page doKqwcDel(Form f, Module m) throws Exception {
		//
		int id = f.getInt("id");	
		return m.getWritePage(f, kqwcManageService.kqwcDel(id));
	}
	
	
}
